#include "u8g2Common.h"
#include "env.h"
void drawWait(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y)
{
    static unsigned char dd = 16;
    static unsigned int ii = 0;
    static u8g2_uint_t x1, y1;
    if (dd >= 16)
    {
        dd = 0;
        ii++;
        switch (ii % 4)
        {
        case 0:
            x1 = x - 5;
            y1 = y - 5;
            break;
        case 1:
            x1 = x+1;
            y1 = y-5;
            break;
        case 2:
            x1 = x+1;
            y1 = y+1;
            break;
        case 3:
            x1 = x-5;
            y1 = y+1;
            break;
        }
    }
    else
    {
        dd++;
    }
    //u8g2_DrawRBox(u8g2, x1, y1, 5, 5, 1);
    u8g2_DrawVLine(u8g2, x-5, y-5, 10);
    u8g2_DrawHLine(u8g2, x-5, y-5, 10);
    u8g2_DrawVLine(u8g2, x+5, y-5, 11);
    u8g2_DrawHLine(u8g2, x-5, y+5, 10);
    u8g2_DrawBox(u8g2, x1, y1, 5, 5);
}

void drawFastChargeLogo(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y)
{
    u8g2_uint_t x1, y1;
    u8g2_uint_t x2, y2;
    u8g2_uint_t x3, y3;
    x1 = x - 4;
    y1 = y;
    x2 = x + 3;
    y2 = y - 9;
    x3 = x;
    y3 = y;
    u8g2_DrawTriangle(u8g2, x1, y1, x2, y2, x3, y3);
    x1 = x + 4;
    y1 = y;
    x2 = x - 2;
    y2 = y + 9;
    x3 = x;
    y3 = y;
    u8g2_DrawTriangle(u8g2, x1, y1, x2, y2, x3, y3);
}

void drawTitle(u8g2_t *u8g2, u8g2_uint_t centerX, u8g2_uint_t centerY, EnvChargerMode chargeMode)
{
    u8g2_uint_t x;
    u8g2_uint_t y;
    // 中心对其
    u8g2_SetFont(u8g2, u8g2_font_spleen16x32_mu);
    switch (env.chargerMode)
    {
    case E_CHARGE_MODE_PD:
        x = centerX - u8g2_GetStrWidth(u8g2, "PD") / 2;
        y = centerY + u8g2_GetAscent(u8g2) / 2;
        u8g2_DrawStr(u8g2, x, y, "PD");
        break;
    case E_CHARGE_MODE_QC:
        x = centerX - u8g2_GetStrWidth(u8g2, "QC") / 2;
        y = centerY + u8g2_GetAscent(u8g2) / 2;
        u8g2_DrawStr(u8g2, x, y, "QC");
        break;
    case E_CHARGE_MODE_NONE:
    default:
        x = centerX - u8g2_GetStrWidth(u8g2, "DC") / 2;
        y = centerY + u8g2_GetAscent(u8g2) / 2;
        u8g2_DrawStr(u8g2, x, y, "DC");
        break;
    }
}
